package com.ars.common.servlet.Login;

import com.ars.common.dao.check;
import com.ars.common.beans.User.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/Login")
public class login extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String password = request.getParameter("password");
        String UserID = request.getParameter("UserID");

        User user = new User();
        user.setUserID(UserID);
        user.setPassword(password);


        System.out.println("login-test");


        try {
            user = new getLogUser().getUser(UserID);
            request.getSession().setAttribute("LogUser", user);
            String url = request.getContextPath() + "/LoadInformationServlet";
//            request.getRequestDispatcher("/LoadInformationServlet").forward(request, response);
            response.sendRedirect(url);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }




    }

}
